/*
William D. Hicks (hickswd@appstate.edu), Carl E. Klarner (Carl.Klarner@gmail.com),  
   Seth C. McKee (sc.mckee@ttu.edu), and Daniel A. Smith (dasmith@ufl.edu)  
   "Revisiting Majority-Minority Districts and Black Representation" in PRQ
*/

/*
Authorship of the data posted here: Carl E. Klarner.  
Authorship of the do-files posted here: William D. Hicks and Carl E. Klarner.  



*ONE MUST DOWNLOAD THE FOLLOWING STATA COMMANDS BEFORE RUNNING THIS CODE.
*This can be done by typing the following into your Stata command line before running any of the code here.  
*ssc install estout, replace
*ssc install combomarginsplot, replace
*ssc install grc1leg, replace
*The immediately above program is by Vince Wiggins in case there is a problem with installation.  

*Note also that Dataverse sometimes alters file formats from Stata to tab delimited files.  Alternate ways of reading in the data are given in "commented out" lines of code in case this occurs so that users can use that code instead.

It reproduces TABLES 1-3, FIGURES 4-5, and FIGURES A1-A2 in 
   Supplemental Materials.  
 
See REPLICATION_CODE_LEGISLATURES to reproduce FIGURES 1a through 3b 

Last updated to this file: 06/01/2018
Second to last update to this file: 09/26/2017 
This file directs the following tasks:
   (1) label/define variables
   (2) reproduce quantities for TABLE 1
   (3) reproduce MODELS for TABLES 2 and 3	  
   (4) reproduce TABLE 2 in a .CSV file
      -TABLE_2_FINAL.csv
   (5) reproduce TABLE 3 in a .CSV file
      -TABLE_3_FINAL.csv
   (6) reproduce FIGURE 4 in a single .pdf file
      -FIGURE_4.pdf
   (7) reproduce FIGURE 5 in a single .pdf file
      -FIGURE_5.pdf
   (8) reproduce FIGURE A1 (Supplemental Materials) in a .pdf file
      -FIGURE_A1.pdf
   (9) reproduce FIGURE A2 (Supplemental Materials) in a .pdf file 
      - FIGURE_A2.pdf
	  
*/

/*
                 YOU NEED TO FIRST IMPORT THE .DTA DATASET
                 THIS REQUIRES THAT YOU WRITE YOUR OWN PATH
*/

clear
version 14.0

*Put directory path where you have the files for import after "cd " in the line below.  
cd 

use REPLICATION_DATA_LEGISLATORS
*The following line can be used instead of the above if Dataverse has converted the Stata files to tab delimited files.  
*import delimited REPLICATION_DATA_LEGISLATORS.tab

/*
            OUTPUT (ALL TABLES & GRAPHS) SAVED TO ~DIRECTORY
*/
*Put directory path to where you want to export files to after "cd " in the line below.  

cd 


/*                           
                    VARIABLE DEFINITIONS AND LABELS
*/

label var senate "Chamber of district (senate=1, house=0)" 
label var election_regime "Election period (1993-95; 2003-05; 2013-15) for district" 
label var elect_black "District elects a black lawmaker (0,1)" 
label var elect_black_dem "District elects a black, Democratic lawmaker (0,1)" 
label var elect_black_rep "District elects a black, Republican lawmaker (0,1)" 
label var elect_republicans "Number of Republicans elected in district (e.g., x>1 if mmd==1)" 
label var elect_democrats "Number of Democrats elected in district (e.g., x>1 if mmd==1)"
label var south "District is in the South (0,1)"   
label var deep_south "District is in the Deep South (0,1)" 
label var rim_south "District is in the Rim South (0,1)" 
label var black1pop "Percentage of district's population that is black" 
label var asian1pop "Percentage of district's population that is Asian" 
label var hisp1pop "Percentage of district's population that is Hispanic" 
label var urbanper "Percentage of district's population that is urban" 
label var open_seat "District had an open seat (0,1)"
label var contested "District had a contested election" 
label var pct_white_obama "Percentage of district's 2008 presidential vote for Barack Obama" 
label var pct_votes_win "Percentage of the district-wide vote earned by winning candidate" 

/* ******************** MEDIANS AND MEANS for TABLE 1 *********************** */

/*    *****   1993----1995    ******  */   
preserve
keep if election_regime==1
/*MEANS AND MEDIANS FOR NON-SOUTH*/
tabstat black1pop hisp1pop asian1pop ///
        if deep_south==0 & rim_south==0 ///
		& elect_black==1, statistics( mean p50 ) ///
        columns(statistics)  format(%12.2f)
	
/*MEANS AND MEDIANS FOR DEEP-SOUTH*/
tabstat black1pop hisp1pop asian1pop ///
        if deep_south==1 & elect_black==1, statistics( mean p50 ) ///
        columns(statistics)  format(%12.2f)		
/*MEANS AND MEDIANS FOR RIM-SOUTH*/
tabstat black1pop hisp1pop asian1pop ///
        if rim_south==1 & elect_black==1, statistics( mean p50 ) ///
        columns(statistics)  format(%12.2f)
restore 

		/*    *****   2003----2005    ******  */   
preserve
keep if election_regime==2
/*MEANS AND MEDIANS FOR NON-SOUTH*/
tabstat black1pop hisp1pop asian1pop ///
        if deep_south==0 & rim_south==0 ///
		& elect_black==1, statistics( mean p50 ) ///
        columns(statistics)  format(%12.2f)
	
/*MEANS AND MEDIANS FOR DEEP-SOUTH*/
tabstat black1pop hisp1pop asian1pop ///
        if deep_south==1 & elect_black==1, statistics( mean p50 ) ///
        columns(statistics)  format(%12.2f)		
/*MEANS AND MEDIANS FOR RIM-SOUTH*/
tabstat black1pop hisp1pop asian1pop ///
        if rim_south==1 & elect_black==1, statistics( mean p50 ) ///
        columns(statistics)  format(%12.2f)
restore

		/*    *****   2013----2015    ******  */   
preserve
keep if election_regime==3
/*MEANS AND MEDIANS FOR NON-SOUTH*/
tabstat black1pop hisp1pop asian1pop ///
        if deep_south==0 & rim_south==0 ///
		& elect_black==1, statistics( mean p50 ) ///
        columns(statistics)  format(%12.2f)
	
/*MEANS AND MEDIANS FOR DEEP-SOUTH*/
tabstat black1pop hisp1pop asian1pop ///
        if deep_south==1 & elect_black==1, statistics( mean p50 ) ///
        columns(statistics)  format(%12.2f)		
/*MEANS AND MEDIANS FOR RIM-SOUTH*/
tabstat black1pop hisp1pop asian1pop ///
        if rim_south==1 & elect_black==1, statistics( mean p50 ) ///
        columns(statistics)  format(%12.2f)
restore


		/*    *****   ALL ELECTION PERIOD  ******  */   
preserve
keep if election_regime>=1 & election_regime<=3 
/*MEANS AND MEDIANS FOR NON-SOUTH*/
tabstat black1pop hisp1pop asian1pop ///
        if deep_south==0 & rim_south==0 ///
		& elect_black==1, statistics( mean p50 ) ///
        columns(statistics)  format(%12.2f)
	
/*MEANS AND MEDIANS FOR DEEP-SOUTH*/
tabstat black1pop hisp1pop asian1pop ///
        if deep_south==1 & elect_black==1, statistics( mean p50 ) ///
        columns(statistics)  format(%12.2f)		
/*MEANS AND MEDIANS FOR RIM-SOUTH*/
tabstat black1pop hisp1pop asian1pop ///
        if rim_south==1 & elect_black==1, statistics( mean p50 ) ///
        columns(statistics)  format(%12.2f)
restore



/************** MODELS REPORTED IN TABLES 2 & 3 **********************/

/*BASE MODELS */


qui logit elect_black c.black1pop i.deep_south  ///
                i.rim_south  ///
                hisp1pop asian1pop ///
				open_seat contested ///
				mmd urbanper senate if election_regime==1  
estimates store black1994

qui logit elect_black c.black1pop i.deep_south  ///
                i.rim_south  ///
                hisp1pop asian1pop ///
				open_seat contested ///
				mmd urbanper senate if election_regime==2  
estimates store black2004

qui logit elect_black c.black1pop i.deep_south  ///
                i.rim_south ///
                hisp1pop asian1pop ///
				open_seat contested ///
				mmd urbanper senate if election_regime==3 
estimates store black2014


/* INTERACTION MODELS */

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
                i.rim_south c.black1pop#i.rim_south ///
                hisp1pop asian1pop ///
				open_seat contested ///
				mmd urbanper senate if election_regime==1   
estimates store black1994_2

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
                i.rim_south c.black1pop#i.rim_south ///
                hisp1pop asian1pop ///
				open_seat contested ///
				mmd urbanper senate if election_regime==2 
estimates store black2004_2

qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
                i.rim_south c.black1pop#i.rim_south ///
                hisp1pop asian1pop ///
				open_seat contested ///
				mmd urbanper senate if election_regime==3
estimates store black2014_2

/*WHITE OBAMA VOTE for 2013-2015 (i.e., TABLE 3)*/


qui logit elect_black c.black1pop i.deep_south ///
                i.rim_south ///
                hisp1pop asian1pop ///
				open_seat contested ///
				mmd urbanper senate pct_white_obama if election_regime==3
estimates store OBAMA_REDUCED


qui logit elect_black c.black1pop i.deep_south c.black1pop#i.deep_south ///
                i.rim_south c.black1pop#i.rim_south ///
                hisp1pop asian1pop ///
				open_seat contested ///
				mmd urbanper senate pct_white_obama if election_regime==3
estimates store OBAMA_FULL

/*OUTCOME IS WINNER IS A BLACK DEMOCRAT (NOT REPORTED)*/

qui melogit elect_black_dem c.black1pop i.deep_south c.black1pop#i.deep_south ///
                i.rim_south c.black1pop#i.rim_south ///
                hisp1pop asian1pop ///
				open_seat contested ///
				mmd urbanper senate if election_regime==1
estimates store black1994_3

qui melogit elect_black_dem c.black1pop i.deep_south c.black1pop#i.deep_south ///
                i.rim_south c.black1pop#i.rim_south ///
                hisp1pop asian1pop ///
				open_seat contested ///
				mmd urbanper senate if election_regime==2
estimates store black2004_3

qui melogit elect_black_dem c.black1pop i.deep_south c.black1pop#i.deep_south ///
                i.rim_south c.black1pop#i.rim_south ///
                hisp1pop asian1pop ///
				open_seat contested ///
				mmd urbanper senate if election_regime==3
estimates store black2014_3


/************** TABLES 2 and 3 **********************/

   
 esttab black1994 black1994_2 black2004 black2004_2 black2014 black2014_2 using TABLE_2_FINAL.csv, ar2 replace ///
   nonumber ///
   mtitles("1993--1995" "1993--1995" "2003--2005" "2003--2005" "2013--2015" "2013--2015") ///
   varlabels(_cons Constant black1pop "% of Population Black" ///
   1.deep_south "Deep South"  ///
   1.rim_south "Rim South"  ///
   1.deep_south#c.black1pop "% of Population Black X Deep South" ///
   1.rim_south#c.black1pop "% of Population Black X Rim South" ///
   hisp1pop "% of Population Hispanic"  ///
   asian1pop "% of Population Asian" ///
   open_seat "Open Seat" ///
   contested "Contested Election" ///
   mmd "Multimember District" ///
   urbanper "% of Population Urban" ///
   senate "Senate" ) ///
   drop(0.deep_south 0.deep_south#c.black1pop ///
   0.rim_south 0.rim_south#c.black1pop) ///
   order(black1pop hisp1pop asian1pop ///
   1.rim_south 1.deep_south 1.rim_south#c.black1pop 1.deep_south#c.black1pop) ///
   cells(b(star fmt(4)) se(par fmt(4))) starlevels(+ 0.10 * 0.05 ** 0.01) ///
   stats(N aic bic) ///
   varwidth(35) style()
   
 esttab OBAMA_REDUCED OBAMA_FULL using TABLE_3_FINAL.csv, ar2 replace ///
   nonumber ///
   mtitles("2013--2015" "2013--2015") ///
   varlabels(_cons Constant black1pop "% of Population Black" ///
   1.deep_south "Deep South"  ///
   1.rim_south "Rim South"  ///
   1.deep_south#c.black1pop "% of Population Black X Deep South" ///
   1.rim_south#c.black1pop "% of Population Black X Rim South" ///
   hisp1pop "% of Population Hispanic"  ///
   asian1pop "% of Population Asian" ///
   open_seat "Open Seat" ///
   contested "Contested Election" ///
   mmd "Multimember District" ///
   urbanper "% of Population Urban" ///
   senate "Senate" ///
   pct_white_obama "% of White Population Voting for Obama") ///
   drop(0.deep_south 0.deep_south#c.black1pop ///
   0.rim_south 0.rim_south#c.black1pop) ///
   order(black1pop hisp1pop asian1pop pct_white_obama ///
   1.rim_south 1.deep_south 1.rim_south#c.black1pop ///
   1.deep_south#c.black1pop) ///
   cells(b(star fmt(4)) se(par fmt(4))) starlevels(+ 0.10 * 0.05 ** 0.01) ///
   stats(N aic bic) ///
   varwidth(35) style()
   
   

   
   
/*************** ESTIMATES FOR FIGURES 4 & 5 **************************/

/* 

THE FOLLOWING CODE REQUIRES USER WRITTEN PROGRAM: combomarginsplot
ssc install combomarginsplot

*/
   
estimates restore black1994_2
quietly margins, at(black1pop=(0(5)100) deep_south=0 rim_south=0 senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_black_1994_nonsouth, replace)
quietly margins, at(black1pop=(0(5)100) deep_south=1 rim_south=0 senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_black_1994_deepsouth, replace)
quietly margins, at(black1pop=(0(5)100) deep_south=0 rim_south=1 senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_black_1994_rimsouth, replace)

quietly margins, dydx(deep_south) at(black1pop=(0(5)100) senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_deepsouth_1994, replace)	
quietly margins, dydx(rim_south) at(black1pop=(0(5)100) senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_rimsouth_1994, replace)	


estimates restore black2004_2
quietly margins, at(black1pop=(0(5)100) deep_south=0 rim_south=0 senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_black_2004_nonsouth, replace)
quietly margins, at(black1pop=(0(5)100) deep_south=1 rim_south=0 senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_black_2004_deepsouth, replace)
quietly margins, at(black1pop=(0(5)100) deep_south=0 rim_south=1 senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_black_2004_rimsouth, replace)

quietly margins, dydx(deep_south) at(black1pop=(0(5)100) senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_deepsouth_2004, replace)	
quietly margins, dydx(rim_south) at(black1pop=(0(5)100) senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_rimsouth_2004, replace)	

estimates restore black2014_2
quietly margins, at(black1pop=(0(5)100) deep_south=0 rim_south=0 senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_black_2014_nonsouth, replace)
quietly margins, at(black1pop=(0(5)100) deep_south=1 rim_south=0 senate=0 mmd=0 open_seat=0 contested=1) saving(margins_black_2014_deepsouth, replace)
quietly margins, at(black1pop=(0(5)100) deep_south=0 rim_south=1 senate=0 mmd=0 open_seat=0 contested=1) saving(margins_black_2014_rimsouth, replace)

quietly margins, dydx(deep_south) at(black1pop=(0(5)100) senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_deepsouth_2014, replace)	
quietly margins, dydx(rim_south) at(black1pop=(0(5)100) senate=0 mmd=0 open_seat=0 contested=1) level(90) saving(margins_rimsouth_2014, replace)	



/*************** FIGURES 4 and 5 **************************/


combomarginsplot margins_black_1994_deepsouth margins_black_2004_deepsouth margins_black_2014_deepsouth, ///
   labels("1993-1995" "2003-2005" "2013-2015") ///
   xlabel(0(5)100, labsize(small)) ///
   ylabel(, nogrid labsize(small)) ///
   title("") ///
   xtitle("Districts' Black Population (percentage)", size(small)) ///
   ytitle("Pr(Black Lawmaker|Deep-South)", size(small)) /// 
   recast(scatter) ///
   yline(0.5, lwidth(vthin) lpattern(solid) lcolor(red)) ///
   xline(50, lwidth(vthin) lpattern(solid) lcolor(red)) ///
   scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
   saving(FIGURE4a, replace)  


combomarginsplot margins_black_1994_rimsouth margins_black_2004_rimsouth margins_black_2014_rimsouth, ///
   labels("1993-1995" "2003-2005" "2013-2015") ///
   xlabel(0(5)100, labsize(small)) ///
   ylabel(, nogrid labsize(small)) ///
   title("") ///
   xtitle("Districts' Black Population (percentage)", size(small)) ///
   ytitle("Pr(Black Lawmaker|Rim-South)", size(small)) /// 
   recast(scatter) ///
   yline(0.5, lwidth(vthin) lpattern(solid) lcolor(red)) ///
   xline(50, lwidth(vthin) lpattern(solid) lcolor(red)) ///
   scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
   saving(FIGURE4b, replace)  


gr combine FIGURE4a.gph FIGURE4b.gph, col(2) scheme(s1mono) ycommon
graph export FIGURE_4.pdf, replace


combomarginsplot margins_deepsouth_1994 margins_deepsouth_2014, ///
   labels("1993-1995" "2013-2015") ///
   xlabel(0(5)100, labsize(small)) ///
   ylabel( , nogrid labsize(small)) ///
   title("") ///
   xtitle("Districts' Black Population (percentage)", size(small)) ///
   ytitle("Marginal Effect of Deep South", size(small)) /// 
   recast(scatter) ///
   yline(0, lwidth(vthin) lpattern(solid) lcolor(red)) ///
   xline(50, lwidth(vthin) lpattern(solid) lcolor(red)) ///
   scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
   saving(FIGURE5a, replace)


combomarginsplot  margins_rimsouth_1994 margins_rimsouth_2014, ///
   labels("1993-1995" "2013-2015") ///
   xlabel(0(5)100, labsize(small)) ///
   ylabel( , nogrid labsize(small)) ///
   title("") ///
   xtitle("Districts' Black Population (percentage)", size(small)) ///
   ytitle("Marginal Effect of Rim South", size(small)) /// 
   recast(scatter) ///
   yline(0, lwidth(vthin) lpattern(solid) lcolor(red)) ///
   xline(50, lwidth(vthin) lpattern(solid) lcolor(red)) ///
   scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
   saving(FIGURE5b, replace)


gr combine FIGURE5a.gph FIGURE5b.gph, col(2) scheme(s1mono) ycommon
graph export FIGURE_5.pdf, replace

/* ************** FIGURE A1 in Supplemental Materials ********************** */

preserve 
keep if elect_black==1
keep if election_regime==1
keep if mmd==0
twoway (scatter pct_votes_win black1pop if south==1, jitter(6) msize(medium) mc(gs6) msymbol(X)) ///
       (scatter pct_votes_win black1pop if south==0, jitter(6) msize(medsmall) mc(gs3) msymbol(Oh)) ///
	   (lowess pct_votes_win black1pop if south==1 & pct_votes_win<90, lpattern(solid) lcolor(gs6)) ///
	   (lowess pct_votes_win black1pop if south==0 & pct_votes_win<90, lpattern(dash) lcolor(gs3)), ///
        yscale( noline) ylabel(, nogrid) ///
        xscale( noline) xlabel() ///
        xtitle("% of Population Black", size(2.5)) ///
        ytitle("% of Votes Earned", size(2.5)) ///
		t1title("1993-1995", size(2.5)) ///
        xsca(titlegap(2)) ///
        ysca(titlegap(2)) ///
	    xline(50, lwidth(vthin) lpattern(solid) lcolor(black)) ///
        scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
	    legend(cols(2) order(1 2 3 4) label(1 "South") ///
        label(2 "Non-South") ///
		label(3 "Trend for the South") ///
		label(4 "Trend for the Non-South") ///
		ring(1) region(c(black) fc(white) lc(black)) ///
        size(vsmall) forcesize bmargin(small)) ///
		saving(FIGURE_A1a, replace)
restore 

preserve 
keep if elect_black==1
keep if election_regime==2
keep if mmd==0
twoway (scatter pct_votes_win black1pop if south==1, jitter(6) msize(medium) mc(gs6) msymbol(X)) ///
       (scatter pct_votes_win black1pop if south==0, jitter(6) msize(medsmall) mc(gs3) msymbol(Oh)) ///
	   (lowess pct_votes_win black1pop if south==1 & pct_votes_win<90, lpattern(solid) lcolor(gs6)) ///
	   (lowess pct_votes_win black1pop if south==0 & pct_votes_win<90, lpattern(dash) lcolor(gs3)), ///
        yscale( noline off) ylabel(, nogrid) ///
        xscale( noline) xlabel() ///
        xtitle("% of Population Black", size(2.5)) ///
        ytitle("% of Votes Earned", size(2.5)) ///
		t1title("2003-2005", size(2.5)) ///
        xsca(titlegap(2)) ///
        ysca(titlegap(2)) ///
	    xline(50, lwidth(vthin) lpattern(solid) lcolor(black)) ///
        scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
	    legend(cols(2) order(1 2 3 4) label(1 "South") ///
        label(2 "Non-South") ///
		label(3 "Trend for the South") ///
		label(4 "Trend for the Non-South") ///
		ring(1) region(c(black) fc(white) lc(black)) ///
        size(vsmall) forcesize bmargin(small)) ///
		saving(FIGURE_A1b, replace)
restore 

preserve 
keep if elect_black==1
keep if election_regime==3
keep if mmd==0
twoway (scatter pct_votes_win black1pop if south==1, jitter(6) msize(medium) mc(gs6) msymbol(X)) ///
       (scatter pct_votes_win black1pop if south==0, jitter(6) msize(medsmall) mc(gs3) msymbol(Oh)) ///
	   (lowess pct_votes_win black1pop if south==1 & pct_votes_win<90, lpattern(solid) lcolor(gs6)) ///
	   (lowess pct_votes_win black1pop if south==0 & pct_votes_win<90, lpattern(dash) lcolor(gs3)), ///
        yscale( noline off) ylabel(, nogrid) ///
        xscale( noline) xlabel() ///
        xtitle("% of Population Black", size(2.5)) ///
        ytitle("% of Votes Earned", size(2.5)) ///
		t1title("2013-2015", size(2.5)) ///
        xsca(titlegap(2)) ///
        ysca(titlegap(2)) ///
	    xline(50, lwidth(vthin) lpattern(solid) lcolor(black)) ///
        scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
	    legend(cols(2) order(1 2 3 4) label(1 "South") ///
        label(2 "Non-South") ///
		label(3 "Trend for the South") ///
		label(4 "Trend for the Non-South") ///
		ring(1) region(c(black) fc(white) lc(black)) ///
        size(vsmall) forcesize bmargin(small)) ///
		saving(FIGURE_A1c, replace)
restore


grc1leg FIGURE_A1a.gph FIGURE_A1b.gph FIGURE_A1c.gph, col(3) scheme(s1mono) ///
        position(6) ycommon
graph export FIGURE_A1.pdf, replace

/* ************** FIGURE A2 in Supplemental Materials ********************** */

preserve 
keep if elect_black==1
keep if election_regime==1
keep if mmd==0
twoway (scatter pct_votes_win black1pop if deep_south==1, jitter(6) msize(medium) mc(gs6) msymbol(X)) ///
       (scatter pct_votes_win black1pop if rim_south==1, jitter(6) msize(medsmall) mc(gs3) msymbol(Oh)) ///
	   (lowess pct_votes_win black1pop if deep_south==1 & pct_votes_win<90, lpattern(solid) lcolor(gs6)) ///
	   (lowess pct_votes_win black1pop if rim_south==1 & pct_votes_win<90, lpattern(dash) lcolor(gs3)), ///
        yscale( noline) ylabel(, nogrid) ///
        xscale( noline) xlabel(0(20)100) ///
        xtitle("% of Population Black", size(2.5)) ///
        ytitle("% of Votes Earned", size(2.5)) ///
		t1title("1993-1995", size(2.5)) ///
        xsca(titlegap(2)) ///
        ysca(titlegap(2)) ///
	    xline(50, lwidth(vthin) lpattern(solid) lcolor(black)) ///
        scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
	    legend(cols(2) order(1 2 3 4) label(1 "Deep South") ///
        label(2 "Rim South") ///
		label(3 "Trend for the Deep South") ///
		label(4 "Trend for the Rim South") ///
		ring(1) region(c(black) fc(white) lc(black)) ///
        size(vsmall) forcesize bmargin(small)) ///
		saving(FIGURE_A2a, replace)
restore 

preserve 
keep if elect_black==1
keep if election_regime==2
keep if mmd==0
twoway (scatter pct_votes_win black1pop if deep_south==1, jitter(6) msize(medium) mc(gs3) msymbol(X)) ///
       (scatter pct_votes_win black1pop if rim_south==1, jitter(6) msize(medsmall) mc(gs6) msymbol(Oh)) ///
	   (lowess pct_votes_win black1pop if deep_south==1 & pct_votes_win<90, lpattern(solid) lcolor(gs3)) ///
	   (lowess pct_votes_win black1pop if rim_south==1 & pct_votes_win<90, lpattern(dash) lcolor(gs6)), ///
        yscale( noline) ylabel(, nogrid) ///
        xscale( noline) xlabel() ///
        xtitle("% of Population Black", size(2.5)) ///
        ytitle("% of Votes Earned", size(2.5)) ///
		t1title("2003-2005", size(2.5)) ///
        xsca(titlegap(2)) ///
        ysca(titlegap(2)) ///
	    xline(50, lwidth(vthin) lpattern(solid) lcolor(black)) ///
        scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
	    legend(cols(2) order(1 2 3 4) label(1 "Deep South") ///
        label(2 "Rim South") ///
		label(3 "Trend for the Deep South") ///
		label(4 "Trend for the Rim South") ///
		ring(1) region(c(black) fc(white) lc(black)) ///
        size(vsmall) forcesize bmargin(small)) ///
		saving(FIGURE_A2b, replace)
restore

preserve 
keep if elect_black==1
keep if election_regime==3
keep if mmd==0
twoway (scatter pct_votes_win black1pop if deep_south==1, jitter(6) msize(medium) mc(gs3) msymbol(X)) ///
       (scatter pct_votes_win black1pop if rim_south==1, jitter(6) msize(medsmall) mc(gs6) msymbol(Oh)) ///
	   (lowess pct_votes_win black1pop if deep_south==1 & pct_votes_win<90, lpattern(solid) lcolor(gs3)) ///
	   (lowess pct_votes_win black1pop if rim_south==1 & pct_votes_win<90, lpattern(dash) lcolor(gs6)), ///
        yscale( noline) ylabel(, nogrid) ///
        xscale( noline) xlabel(0(20)100) ///
        xtitle("% of Population Black", size(2.5)) ///
        ytitle("% of Votes Earned", size(2.5)) ///
		t1title("2013-2015", size(2.5)) ///
        xsca(titlegap(2)) ///
        ysca(titlegap(2)) ///
	    xline(50, lwidth(vthin) lpattern(solid) lcolor(black)) ///
        scheme (s2mono) graphregion(fcolor(white) icolor(white) lcolor(white)) ///
	    legend(cols(2) order(1 2 3 4) label(1 "Deep South") ///
        label(2 "Rim South") ///
		label(3 "Trend for the Deep South") ///
		label(4 "Trend for the Rim South") ///
		ring(1) region(c(black) fc(white) lc(black)) ///
        size(vsmall) forcesize bmargin(small)) ///
		saving(FIGURE_A2c, replace)
restore


grc1leg FIGURE_A2a.gph FIGURE_A2b.gph FIGURE_A2c.gph, col(3) scheme(s1mono) ///
        position(6) ycommon
graph export FIGURE_A2.pdf, replace

